The invention relates to a mixed-mode-simulator interface for time-advance synchronizing a simulator having analog and digital portions thereto, and specifically to such an interface wherein the simulation in a digital realm is event-drive by that in the analog realm, and simulation in the analog realm is sensitive to changes in the event-driven realm.
A mixed mode simulator handles simulations which occur in what is generally referred to as analog and digital realms by solving mathematical models of real-world devices or elements. An analog simulator is described in my co-pending applications, Ser. No. 06/918,383, filed Oct. 14, 1986, for SYSTEM PERFORMANCE SIMULATOR, and a continuation of that case, Ser. No. 07/264,383, filed Oct. 31, 1988. Analog, or continuous, function elements are represented by mathematical models which consist of integrodifferential and/or algebraic equations which are continuous in time. Digital, or discreet, function elements are represented by mathematical models which consist of algebraic equations which are discontinuous in time.
The results of a simulation are waveforms, either continuous or discontinuous in value. The results of a simulation, however, can only be sampled by a simulator at specific points in time. The distance between these time points, called a time step, can be fixed (determined before the simulation by a parameter) or a variable (determined by an algorithm in the simulator). At each time step, either all outputs from the models, which simulate a real-world element, can be reported, or only those outputs which have a value changed from that of the previous time point may be reported.
Digital simulators are generally operated on a fixed-time step regimen, and therefore operate in discrete time blocks. The time step is referred to as time resolution and may be either predetermined by the simulator or assignable by the user. Regardless of how the time step is determined, time can be increased, during simulation, only in multiples of the time resolution.
The most basic digital simulator advances time by one step and evaluates outputs of all models based on their present and past inputs repeatedly until nothing changes, and then advances to the next time point. This approach is extremely inefficient and wastes time in evaluating models whose inputs have not changed.
In digital simulation, outputs of a model of a passive element can change only in response to a previous change of an input. Output of an active element, for example a stimulus or a clock, can occur spontaneously, but only at predetermined time points. It would be more efficient to consider only those models whose inputs have changed. In such an approach, many unnecessary evaluations are by-passed at each time point and, there may in fact be many time points when there are no changes.
A digital simulator may be constructed to be event-driven. As used herein, event-driven means that the simulation results in an output which has values which may be either continuous or discreet in nature. The event-driven simulation algorithm may be derived such that a queue of future events is maintained. The event queue also maintains output changes and the time at which they occur, and, after each evaluation, advances time to the next event, and evaluates only those models whose inputs have changed. The evaluation will allow the models in the simulator to enter or schedule events at some future time on a queue. This algorithm may be summarized as follows:
______________________________________ At time = 0, enter all spontaneous events into the queue repeat { Advance time to the time of the next event on the queue. Assign the new output values that were saved on the queue. For all elements whose input were changed in the previous step, evaluate the models. ______________________________________
An integration algorithm is used in an analog simulator to define an approximate solution to a mathematical problem or model, which may represent an analog, continuous function real-world element or device. Many different formulations may be employed, the most general being: EQU f(x,x,t)=0
Where x represents the unknowns, x represent the time derivatives of the unknowns, t is the time and f is the nonlinear relationship between the quantities.
As noted earlier, the solution is a waveform which is sampled at possibly irregular intervals. If a solution at previous time points, t.sub.n-1, t.sub.n-2 . . . t.sub.n-k is known, and is denoted by x.sub.n-1, x.sub.n-2 . . . X.sub.n-k and x.sub.n-1, x.sub.n-2 . . . x.sub.n-k, a time step h may be found to solve the algorithm for x.sub.n and x.sub.n at a future time t.sub.n =t.sub.n-1 +h.
A class of integration formula called Linear Multi-Step (LMS) formulas assumes that the solution x can be approximated in time by a polynomial. From this assumption, a relationship between the various quantities may be derived and represented by: ##EQU1## where h.sub.i equals t.sub.n-1 -t.sub.n-i-1.
By carefully choosing coefficients .alpha..sub.i and .beta..sub.i, various well known algorithms may be derived, such as the Euler Forward and Backward, Gear of Orders 1-6, and Trapezoidal. In any of these algorithms, a rearrangement of the above formula leads to an approximation of the derivative at time t.sub.n, based on past values of x and x and possibly the new value x.sub.n where: ##EQU2## This relationship, substituted into the original problem, leads to an algebraic equation in x.sub.n : EQU g(x.sub.n)=r(x.sub.n-i,x.sub.n-i,t.sub.n)
which may be solved by any number of numerical algorithms, such as the Newton-Raphson or the Katzenelson algorithms.
For practical implementations of the formulas, both of the order of integration (k) and the step size (h) may vary during simulation. For example, during startup, or initialization, first order integration has to be used, since no history is yet available. The accuracy of a solution depends on the size of the step. Generally, the shorter the step, the better the accuracy, however, additional work must be performed to solve the algorithms a greater number of times when using shorter time steps. In addition, the accuracy of a result at time t.sub.n may only be determined after x.sub.n is determined. If the achieved accuracy is not acceptable, the step must be discarded and a shorter step, i.e., smaller h, used. This experimentation is generally referred to as backtracking and is costly in processing time. The ideal algorithm would always guess just the right time step h to get the required accuracy, and would not select an h which was any smaller than that required to get the proper accuracy.
In known logic simulators, a variety of techniques are used to bring the simulated system up to a "steady" state condition. Some logic simulators begin at real-world system turnon. Others assume a steady state and require that the user initialize the system. Some analog simulators, such as Spice, perform an initialization at all times, regardless of whether it is really necessary to initialize the system or not. The interface of the invention allows the user to select, or allows the integration algorithms of the simulators to select, whether or not initialization is required before entering the transient phase of the simulation.
In mixed-mode simulation, both the event-driven and the integration algorithms must co-exist and cooperate. One way of achieving this is to have both algorithms work in the same simulation time, and let the time step be determined jointly by the two algorithms. This lock-step approach means that at each time step, determined by the event queue, the analog values x.sub.n are calculated, and also that the next time at which the integration algorithm is to be applied is entered into the event queue as an event. Threshold crossing times may be determined at the end of each time step and one of two procedures may be followed: (1) the threshold crossing may be deemed to have occurred at the end of the step, and is entered as an event into the queue at that time. This is potentially inaccurate, since in slowly varying systems, the analog time step may be much longer than any delay through the event-driven (digital) portion of the simulator; or (2) the time of the threshold crossing may be determined from x.sub.n and x.sub.n-1 by interpolation and the analog simulator instructed to backtrack to that time in order to keep the two algorithms time synchronized. This is potentially costly in processor time.
A more efficient way to time synchronize analog and digital portions of a simulator is to allow events in the analog realm to drive events in the digital realm and to make events in the analog realm sensitive to changing events in the event-driven realm.